/*     */ package com.qmsk.business.store.transferbilldtl.controller;
/*     */ 
/*     */ import com.qmsk.business.store.transferbilldtl.dao.TransferDtlDAO;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"transferDtl"})
/*     */ public class TransferDtlController
/*     */ {
/*  30 */   private static final Logger logger = Logger.getLogger(TransferDtlController.class);
/*     */ 
/*     */   @Autowired
/*     */   private TransferDtlDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  40 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  42 */       Map params = new HashMap();
/*  43 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*  44 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  45 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  47 */       logger.error(e);
/*  48 */       ResponseUtils.setErrorMsgResponse(
/*  49 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/*  57 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(id);
/*  58 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  60 */       logger.error(e);
/*  61 */       ResponseUtils.setErrorMsgResponse(
/*  62 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/*  80 */       int nResult = 0;
/*     */ 
/*  82 */       String sData = RequestUtils.getStringOfData(request);
/*  83 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*     */ 
/*  85 */       nResult = this.dao.applyUpdates(p, "id");
/*     */ 
/*  87 */       if (nResult > 0)
/*  88 */         DbConnection.commit();
/*     */       else {
/*  90 */         DbConnection.rollback();
/*     */       }
/*     */ 
/*  97 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  98 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  99 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 102 */       logger.error(e);
/* 103 */       DbConnection.rollback();
/* 104 */       ResponseUtils.setErrorMsgResponse(
/* 105 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 106 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}/{id}/{sendRange}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("id") Long id, @PathVariable("sendRange") Integer sendRange)
/*     */   {
/*     */     try
/*     */     {
/* 125 */       int nResult = 0;
/* 126 */       String sData = RequestUtils.getStringOfData(request);
/* 127 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 128 */       if (p != null) {
/* 129 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 131 */       if (nResult > 0)
/* 132 */         DbConnection.commit();
/*     */       else {
/* 134 */         DbConnection.rollback();
/*     */       }
/* 136 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 137 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 138 */         response);
/*     */     } catch (Exception e) {
/* 140 */       logger.error(e);
/* 141 */       DbConnection.rollback();
/* 142 */       ResponseUtils.setErrorMsgResponse(
/* 143 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 144 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 160 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 162 */       String[] strParams = id.split(",");
/* 163 */       int nResult = this.dao.deleteParams(strParams);
/* 164 */       if (nResult > 0)
/* 165 */         DbConnection.commit();
/*     */       else {
/* 167 */         DbConnection.rollback();
/*     */       }
/* 169 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 170 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 171 */         response);
/*     */     } catch (Exception e) {
/* 173 */       DbConnection.rollback();
/* 174 */       logger.error(e);
/* 175 */       ResponseUtils.setErrorMsgResponse(
/* 176 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 177 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.transferbilldtl.controller.TransferDtlController
 * JD-Core Version:    0.5.3
 */